home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / gfx / 3d / irit50src.lha / irit5 / contrib / skeleton / skel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-28  |  4.4 KB  |  108 lines

  1. /*****************************************************************************
  2. * Skeleton for an interface to a parser to read IRIT data files.         *
  3. *                                         *
  4. * Written by:  Gershon Elber                Ver 1.0, Feb 1993    *
  5. *****************************************************************************/
  6.  
  7.  
  8. #include <stdio.h>
  9. #include "irit_sm.h"
  10. #include "cagd_lib.h"
  11. #include "symb_lib.h"
  12. #include "iritprsr.h"
  13. #include "attribut.h"
  14. #include "allocate.h"
  15.  
  16. /*****************************************************************************
  17. * DESCRIPTION:                                                               M
  18. * Main module of skeletn1 - Read command line and do what is needed...         M
  19. *                                                                            *
  20. * PARAMETERS:                                                                M
  21. *   argc, argv:  Command line.                                               M
  22. *                                                                            *
  23. * RETURN VALUE:                                                              M
  24. *   void                                                                     M
  25. *                                                                            *
  26. * KEYWORDS:                                                                  M
  27. *   main                                                                     M
  28. *****************************************************************************/
  29. void main(int argc, char **argv)
  30. {
  31.     IPObjectStruct *PObjects, *PObj;
  32.  
  33.     /* Get the data from the input stream: */
  34.     if ((PObjects = IritPrsrGetObjects(stdin)) == NULL)
  35.     exit(1);
  36.  
  37.     /* Print the read geometry to stdout. */
  38.     for (PObj = PObjects; PObj != NULL; PObj = PObj -> Pnext)
  39.     IritPrsrPutObject(stdout, PObj);
  40.  
  41.     /* Do some symbolic manipulation of curves: */
  42.     for (PObj = PObjects; PObj != NULL; PObj = PObj -> Pnext)
  43.     {
  44.     if (IP_IS_CRV_OBJ(PObj)) {
  45.         char *Err;
  46.         CagdCrvStruct
  47.             *DerivCrv = CagdCrvDerive(PObj -> U.Crvs),
  48.         *DegreeRaiseCrv = CagdCrvDegreeRaise(PObj -> U.Crvs),
  49.         *TanMagSqr = SymbCrvDotProd(DerivCrv, DerivCrv),
  50.             *DiffZero = SymbCrvSub(PObj -> U.Crvs, DegreeRaiseCrv);
  51.         CagdSrfStruct
  52.             *SrfOfRev = CagdSurfaceRev(PObj -> U.Crvs),
  53.         *SweepSrf = CagdSweepSrf(PObj -> U.Crvs, PObj -> U.Crvs,
  54.                      NULL, 1.0, NULL, FALSE);
  55.  
  56.         CagdCrvWriteToFile2(DiffZero, stdout, 0, "A Zero Curve", &Err);
  57.         CagdCrvWriteToFile2(TanMagSqr, stdout, 0,
  58.                 "Magnitude of Tangent Square", &Err);
  59.         CagdCrvFree(DiffZero);
  60.         CagdCrvFree(TanMagSqr);
  61.         CagdCrvFree(DegreeRaiseCrv);
  62.  
  63.         CagdSrfWriteToFile2(SrfOfRev, stdout, 0, "A Surface of revolution",
  64.                 &Err);
  65.         CagdSrfWriteToFile2(SweepSrf, stdout, 0, "A Sweep Surface",
  66.                 &Err);
  67.  
  68.         CagdSrfFree(SrfOfRev);
  69.         CagdSrfFree(SweepSrf);
  70.     }
  71.     }
  72. }
  73.  
  74. /*****************************************************************************
  75. * DESCRIPTION:                                                               M
  76. * Routine to process all surfaces/curves. Only concatenates the freeform     M
  77. * geometry into one linked list.                         M
  78. *   This function is a call back function of the irit parser.             M
  79. *                                                                            *
  80. * PARAMETERS:                                                                M
  81. *   CrvObjs:   Curve objects found on input stream.                          M
  82. *   SrfObjs:   Surface objects found on input stream.                        M
  83. *                                                                            *
  84. * RETURN VALUE:                                                              M
  85. *   IPObjectStruct *:   Linked list of both curves and surfaces.             M
  86. *                                                                            *
  87. * KEYWORDS:                                                                  M
  88. *   IritPrsrProcessFreeForm                                                  M
  89. *****************************************************************************/
  90. IPObjectStruct *IritPrsrProcessFreeForm(IPObjectStruct *CrvObjs,
  91.                     IPObjectStruct *SrfObjs)
  92. {
  93.     fprintf(stderr, "IritPrsrProcessFreeForm invoked from the IritPrsr.\n");
  94.  
  95.     if (CrvObjs == NULL)
  96.     return SrfObjs;
  97.     else if (SrfObjs == NULL)
  98.     return CrvObjs;
  99.     else {
  100.     IPObjectStruct *PTmp = CrvObjs;
  101.  
  102.     while (PTmp -> Pnext)
  103.         PTmp = PTmp -> Pnext;
  104.     PTmp -> Pnext = SrfObjs;
  105.     return CrvObjs;
  106.     }
  107. }
  108.